#include <stdio.h>
#include <stdlib.h>
typedef struct node
{
    int data;
    struct node* next;
}Node;
Node* init();
Node* test(Node * a);
void print(Node * phead);
int main()
{
    Node * head = init();
    print(head);
    printf("\n");
    Node* phead = test(head);
    print(phead);
    printf("\n");
    return 0;
}
Node* init()
{
    Node *a = malloc(sizeof(Node));
    Node *b = malloc(sizeof(Node));
    Node *c = malloc(sizeof(Node));
    Node *d = malloc(sizeof(Node));
    Node *e = malloc(sizeof(Node));
    a->data = 1;
    b->data = 2;
    c->data = 3;
    d->data = 4;
    e->data = 5;
    a->next = b;
    b->next = c;
    c->next = d;
    d->next = e;
    e->next = NULL;
    return a;
}
Node* test(Node * a)
{
    Node *x = NULL,* y = a,*z = a->next;
    while(y != NULL)
    {
        y->next = x;
        x= y;
        y = z;
        if(z)
            z = z->next;
    }
    return x;
}
void print(Node * phead)
{
    Node * cur = phead;
        while(cur != NULL)
        {
            printf("%d ",cur->data);
            printf("--->");
            cur = cur->next;
        }
        printf("NULL");
}
